﻿using System.Collections.Generic;
using System.Windows.Documents;

namespace HyperplaneTech.CdrPlugin {

    /// <summary>
    /// 通用的JSON返回结果对象
    /// </summary>
    /// <typeparam name="T">泛型对象</typeparam>
    public class JsonResult<T> {

        /// <summary>
        /// 响应代码
        /// </summary>
        public int code { get; set; }

        /// <summary>
        /// 响应消息
        /// </summary>
        public string msg { get; set; }

        /// <summary>
        /// 响应时间戳
        /// </summary>
        public long ts { get; set; }

        /// <summary>
        /// 响应数据
        /// </summary>
        public T data { get; set; }

        /// <summary>
        /// 扩展数据，可以是任何信息
        /// </summary>
        public object extra { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        /// <returns>如果状态码为200表示成功</returns>
        public bool IsSuccess() {
            return code == 200;
        }
    }


    /// <summary>
    /// 合并形状数据DTO
    /// </summary>
    internal class MergedDataDto {

        /// <summary>
        /// 整体群组区域
        /// </summary>
        public ShapeSizeDto rect { get; set; }

        /// <summary>
        /// 群组区域内的形状列表
        /// </summary>
        public List<ShapeSizeDto> rectList { get; set; }

    }

    /// <summary>
    /// 形状尺寸DTO
    /// </summary>
    internal class ShapeSizeDto {

        /// <summary>
        /// 宽度
        /// </summary>
        public double width { get; set; }

        /// <summary>
        /// 高度
        /// </summary>
        public double height { get; set; }

        /// <summary>
        /// X
        /// </summary>
        public double x { get; set; }

        /// <summary>
        /// Y
        /// </summary>
        public double y { get; set; }

    }

}
